package com.oamicnet.boot.mybatis.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oamicnet.boot.mybatis.entity.Teacher;
import com.oamicnet.boot.mybatis.mapper.TeacherMapper;
import com.oamicnet.boot.mybatis.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TeacherServiceImpl extends ServiceImpl implements TeacherService {

    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    public List<Teacher> findAll() {
        return teacherMapper.selectList(null);
    }

    @Override
    public void save(Teacher teacher) {
        teacherMapper.insert(teacher);
    }

    @Override
    public void update(Teacher teacher) {
        teacherMapper.updateById(teacher);
    }

    @Override
    public Teacher get(Long id) {
        return teacherMapper.selectById(id);
    }

    @Override
    public void delete(Long id) {
        teacherMapper.deleteById(id);
    }
}
